package com.student.client.controller;

import com.student.client.entity.Medicine;
import com.student.client.service.MedicineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class MedicineController {
    //查询所有药品信息记录接口
    @Autowired
    MedicineService medicineService;

    @RequestMapping("/medicine")
    public List<Medicine> getMedicine() {

        return medicineService.findAllMedicine();
    }
    //添加药品信息记录接口
    @PostMapping("/addMedicine")
    public Integer getMedicine(@RequestParam String name,
                                 @RequestParam int number,
                                 @RequestParam String date,
                                 @RequestParam String context) {
        Medicine medicine = new Medicine(null, name, number, date, context);
        return medicineService.addMedicine(medicine);
    }
}
